package com.zb.controller;


import com.zb.entity.dto.ClauseDto;
import com.zb.result.Result;
import com.zb.service.ZjAdmClauseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apiguardian.api.API;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 后台条款表 前端控制器
 * </p>
 *
 * @author WEN
 * @since 2023-07-07
 */
@Api(tags = "条款类接口")
@RestController
@RequestMapping("/clause")
public class ZjAdmClauseController {
    @Autowired
    private ZjAdmClauseService admClauseService;

    @ApiOperation("新增或修改条款")
    @PostMapping("/save")
    public Result save(@RequestBody @Valid ClauseDto clauseDto) {
        admClauseService.save(clauseDto);
        return Result.success(null == clauseDto.getId()? "条款添加成功" : "条款更新成功");
    }

    @ApiOperation("根据条款类型获取条款信息")
    @GetMapping("/{type}")
    public Result getClaus(@PathVariable @ApiParam("条款类型：1-注册条款，2-登录条款，3-使用条款") Integer type) {
        return Result.success("获取条款成功！").data("row", admClauseService.getClaus(type));
    }

}
